package com.action;

import java.util.List;

import com.entity.Book;
import com.entity.Category;
import com.service.BookService;
import com.service.CategoryService;
import com.service.Impl.BookServiceImpl;
import com.service.Impl.CategoryServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

@Controller
@Scope("prototype")
public class BookAction {
	@Autowired
	private BookService service;
	@Autowired
	private CategoryService service1;
	private List<Book> bookBySale;
	private List<Book> bookByEditor;
	private List<Book> bookByTime;
	private List<Book> bookByPrice;
	private List<Category> category;
	private Integer parentId;
	private List<Book> bookByCategory;
	private Category c;
	private Integer count;
	private Integer categoryId;
	private List<Book> bookBySearch;
	private String bookName;
	private Book b;
	private Integer bookId;
	public Book getB() {
		return b;
	}
	public void setB(Book b) {
		this.b = b;
	}
	public Integer getBookId() {
		return bookId;
	}
	public void setBookId(Integer bookId) {
		this.bookId = bookId;
	}
	public String getBookName() {
		return bookName;
	}
	public void setBookName(String bookName) {
		this.bookName = bookName;
	}
	public List<Book> getBookBySearch() {
		return bookBySearch;
	}
	public void setBookBySearch(List<Book> bookBySearch) {
		this.bookBySearch = bookBySearch;
	}
	public List<Book> getBookByCategory() {
		return bookByCategory;
	}
	public void setBookByCategory(List<Book> bookByCategory) {
		this.bookByCategory = bookByCategory;
	}
	public Integer getCategoryId() {
		return categoryId;
	}
	public void setCategoryId(Integer categoryId) {
		this.categoryId = categoryId;
	}
	public Integer getCount() {
		return count;
	}
	public void setCount(Integer count) {
		this.count = count;
	}
	public Category getC() {
		return c;
	}
	public void setC(Category c) {
		this.c = c;
	}
	public Integer getParentId() {
		return parentId;
	}
	public void setParentId(Integer parentId) {
		this.parentId = parentId;
	}
	public List<Book> getBookByPrice() {
		return bookByPrice;
	}
	public void setBookByPrice(List<Book> bookByPrice) {
		this.bookByPrice = bookByPrice;
	}
	public List<Category> getCategory() {
		return category;
	}
	public void setCategory(List<Category> category) {
		this.category = category;
	}
	public List<Book> getBookByEditor() {
		return bookByEditor;
	}
	public void setBookByEditor(List<Book> bookByEditor) {
		this.bookByEditor = bookByEditor;
	}
	public List<Book> getBookByTime() {
		return bookByTime;
	}
	public void setBookByTime(List<Book> bookByTime) {
		this.bookByTime = bookByTime;
	}
	public List<Book> getBookBySale() {
		return bookBySale;
	}
	public void setBookBySale(List<Book> bookBySale) {
		this.bookBySale = bookBySale;
	}
	public String show(){
		category=service1.selectAll();
		bookBySale=service.showBySale();
		bookByEditor=service.showByEditor();
		bookByTime=service.showByTime();
		bookByPrice=service.showByPrice();
		return "show";
	}
	public String showByFCategory(){
		bookByCategory=service.showByFCategory(parentId);
		c=service1.selectByParent(parentId);
		return "showByFCategory";
	}
	public String showBySCategory(){
		bookByCategory=service.showBySCategory(categoryId);
		c=service1.selectByCategoryId(categoryId);
		return "showBySCategory";
	}
	public String showBySearch(){
		bookBySearch=service.showBySearch(bookName);
		category=service1.selectBySearch(bookName);
		return "toBookSearch";
	}
	public String showOne(){
		b=service.showOne(bookId);
		System.out.println(b);
		return "showOne";
	}
}
